<?php include "menu.phtml"; $userTypes = array("1" => $this->translate->_("Pet Owner"), "2" => $this->translate->_("Service Provider")); ?>
<div id="right">
	<div class="rightbox">
		<div class="context"><div class="in"><a href="javascript:void(0);" id="context_menu" class="icon_link the_down"><span></span></a></div></div>
		<h1><?php echo $this->translate->_("My Friends"); ?></h1>
		<br />
		<?php if(isset($this->friends) && count($this->friends) > 0): ?>
			<?php echo $this->paginationControl($this->friends, 'Elastic', 'pagination-controls.phtml', array('pos' => 'top')); ?>
			<?php
				echo $this->partial('user-template.phtml', array(
					'translate' => $this->translate,
					'usertypes' => $userTypes,
					'data' => $this->friends,
					'identity' => $this->identity,
					'links' => 'remove',
					'per_row' => 2
				));
			?>
			<?php echo $this->paginationControl($this->friends, 'Elastic', 'pagination-controls.phtml', array('pos' => 'bot')); ?>
		<?php else: ?>
			<b class="red bigger"><?php echo $this->translate->_("No friends."); ?></b>
		<?php endif; ?>
	</div>
	<div class="rightbox">
		<div class="left" style="width: 391px;">
			<h3><?php echo $this->translate->_("Friend Requests"); ?></h3>
			<br />
			<?php if(isset($this->requests) && count($this->requests) > 0): ?>
				<table cellspacing="0" cellpadding="5" class="grid">
				<col width="200" /><col width="145" />
					<tr>
						<th><?php echo $this->translate->_("Name"); ?></th>
						<th></th>
					</tr>
					<?php foreach($this->requests as $user): ?>
						<tr>
							<td>
								<a href="<?php echo $this->url(array('controller'=>'accounts', 'action'=>'view', 'user' => $user['id']), 'default', true); ?>">
									<?php echo $user['name']; ?>
								</a>
							</td>
							<td align="right" nowrap="nowrap">
								<a class="icon_link accept" href="<?php echo $this->url(array('controller'=>'friends', 'action'=>'accept-friendship', 'id' => $user['link_id']), 'default', true); ?>"><span><?php echo $this->translate->_("Accept"); ?></span></a>
								<a class="icon_link deny" href="<?php echo $this->url(array('controller'=>'friends', 'action'=>'decline-friendship', 'id' => $user['link_id']), 'default', true); ?>"><span><?php echo $this->translate->_("Decline"); ?></span></a>
							</td>
						</tr>
					<?php endforeach; ?>
				</table>
			<?php else: ?>
				<b class="red bigger"><?php echo $this->translate->_("No friend requests."); ?></b>
			<?php endif; ?>
		</div>
		<div class="right" style="width: 391px;">
			<h3><?php echo $this->translate->_("Pending Friends"); ?></h3>
			<br />
			<?php if(isset($this->pending) && count($this->pending) > 0): ?>
				<table cellspacing="0" cellpadding="5" class="grid">
				<col width="200" /><col width="145" />
					<tr>
						<th><?php echo $this->translate->_("Name"); ?></th>
						<th></th>
					</tr>
					<?php foreach($this->pending as $user): ?>
						<tr>
							<td>
								<a href="<?php echo $this->url(array('controller'=>'accounts', 'action'=>'view', 'user' => $user['id']), 'default', true); ?>">
									<?php echo $user['name']; ?>
								</a>
							</td>
							<td align="right">&nbsp;</td>
						</tr>
					<?php endforeach; ?>
				</table>
			<?php else: ?>
				<b class="red bigger"><?php echo $this->translate->_("No pending friends."); ?></b>
			<?php endif; ?>
		</div>
		<div class="clear"></div>
	</div>
</div>
<script type="text/javascript">
	var Privacy = function() {
		function hideFields() {
			$('[class*="private"], [class*="empty"]').each(function(s, i){
				var td = $(i).parent().parent();
				$(i).parent().remove();

				if(!td.has('span').length > 0)
					td.find('div').remove();
			});
		};

		function __construct() {
			hideFields();
		};

		return {
			init: __construct
		}
	}();

	READY(Privacy.init);
</script>